

import 'dart:async';
import 'dart:ffi';
import 'package:rxdart/rxdart.dart';

import 'package:luckin_demo/blocdemo/validators.dart';

class Bloc extends Object with Validators implements BaseBloc{
   final _emailController = BehaviorSubject<String>();
  final _passwordController =  BehaviorSubject<String>();

   Function(String) get emailChanged => _emailController.sink.add;
   Function(String) get passwordChanged => _passwordController.sink.add;

   Stream<String> get email => _emailController.stream.transform(emailValidator);
   Stream<String> get password => _passwordController.stream.transform(passwordValidator);
  //rx 做流处理
   Stream<bool> get submitCheck => Rx.combineLatest2(email,password,(e,p)=>true); //prints 1, 2, 3

  @override
  void dispose() {
    // TODO: implement dispose
    _emailController.close();
    _passwordController.close();
  }



}

abstract class BaseBloc{
  void dispose();


}